var t = require("../../utils/config.js");

require("../../utils/util.js");

Page({
    data: {
        timer: null,
        isCanSend: !0,
        count: 60,
        mobile: "",
        code: "",
        userId: ""
    },
    onLoad: function(t) {},
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getMobile: function(t) {
        this.setData({
            mobile: t.detail.value
        });
    },
    getCode: function(t) {
        this.setData({
            code: t.detail.value
        });
    },
    sendCode: function() {
        var a = this;
        a.data.mobile ? (wx.showLoading({
            mask: !0
        }), wx.request({
            url: t.urlList.API_USER_SEND_SMS_FOR_FORGET_PASSWORD,
            method: "POST",
            header: {
                contentType: "application/json"
            },
            data: {
                mobile: a.data.mobile
            },
            success: function(t) {
                wx.hideLoading(), 200 == t.data.status ? (console.log(t.data.data), a.setData({
                    userId: t.data.data.userId
                }), a.countDown()) : wx.showToast({
                    title: t.data.message,
                    icon: "none"
                });
            }
        })) : wx.showToast({
            title: "请输入手机号码",
            icon: "none"
        });
    },
    countDown: function() {
        var t = this, a = t.data.count;
        a >= 1 ? (a--, t.data.timer = setTimeout(function() {
            t.setData({
                count: a,
                isCanSend: !1
            }), t.countDown();
        }, 1e3)) : (clearTimeout(t.data.timer), t.setData({
            timer: null,
            isCanSend: !0,
            count: 60
        }));
    },
    next: function() {
        var a = this;
        a.data.mobile ? a.data.code ? (wx.showLoading({
            mask: !0
        }), wx.request({
            url: t.urlList.API_USER_CHECK_FORGET_PASSWORD_CODE,
            method: "POST",
            data: {
                mobile: a.data.mobile,
                code: a.data.code
            },
            header: {
                contentType: "application/json"
            },
            success: function(t) {
                wx.hideLoading(), 200 == t.data.status ? wx.navigateTo({
                    url: "../my/updatePassword?userId=" + t.data.data.userId
                }) : wx.showToast({
                    title: t.data.message,
                    icon: "none"
                });
            }
        })) : wx.showToast({
            title: "请输入验证码",
            icon: "none"
        }) : wx.showToast({
            title: "请输入手机号码",
            icon: "none"
        });
    }
});